package com.example.asus.testskip;

import android.content.Context;
import android.graphics.PixelFormat;
import android.view.WindowManager;
import android.widget.TextView;

/**
 * Created by ASUS on 2019/7/18.
 */

public class ViewUtils {

    public static void callView(Context context, String phoneNumber) {
        WindowManager mWinMgr = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
        params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        params.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.format = PixelFormat.RGBA_8888;
        TextView mTxtView = new TextView(context);
        mTxtView.setText("悬浮窗，来电号码：" + phoneNumber);
        //mTxtView.setBackgroundColor(0x00000000);
        mTxtView.setTextColor(0xFFFFFFFF);
        mWinMgr.addView(mTxtView, params);
    }
}
